package com.chenyuxin.ilp.security.auth.handler;

import com.chenyuxin.ilp.model.enums.exception.ExceptionEnums;
import com.chenyuxin.ilp.model.enums.exception.UserExceptionEnums;
import lombok.Getter;
import org.springframework.security.core.AuthenticationException;


// 登录异常类（能被AuthenticationFailureHandler识别）
@Getter
public class LoginException extends AuthenticationException {
    private final Integer code;
    // 通过枚举来构造异常
    public LoginException(UserExceptionEnums exceptionEnum) {
        super(exceptionEnum.getErrorMessage()); // 设置 message
        this.code = exceptionEnum.getCode();
    }
    public LoginException(ExceptionEnums exceptionEnum) {
        super(exceptionEnum.getErrorMessage()); // 设置 message
        this.code = exceptionEnum.getCode();
    }
    // 普通构造器
    public LoginException(Integer code, String message) {
        super(message);
        this.code = code;
    }
}
